package me.tuyou.activiti.taskService;

import me.tuyou.activiti.Base;
import org.activiti.engine.task.Task;
import org.junit.Test;

public class SimpleConditionBranchTest extends Base {

    @Test
    public void deploy() {
        repositoryService.createDeployment().addClasspathResource("SimpleConditionBranch.bpmn").name("流程线搭配条件").deploy();
    }

    @Test
    public void startInstance() {
        runtimeService.startProcessInstanceByKey("SimpleConditionBranch");
    }

    /**
     * 部门经理审批
     */
    @Test
    public void deptManagerAudit() {
        Task task = taskService.createTaskQuery().taskAssignee("tuyou").singleResult();
//        taskService.setVariable(task.getId(), "message", "重要");
        taskService.setVariable(task.getId(), "message", "不重要");

        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }

    /**
     * 总经理审批
     */
    @Test
    public void generalManagerAudit() {
        Task task = taskService.createTaskQuery().taskAssignee("yangrui").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }
}
